home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
C
/
Frameworks
/
TransSkel 3.24
/
Source
/
SkelCmdPeriod.c
< prev
next >
Wrap
Text File
|
1996-01-17
|
2KB
|
73 lines
/*
* SkelCmdPeriod.c -- Figure out, in an internationally compatible way, whether
* an event is a command-period key event.
*
* See TN TE 23, International Cancelling, for the rationale on how this works.
*/
# include <Script.h>
# include "TransSkel.h"
# define kMaskModifiers 0xfe00
# define kMaskVirtualKey 0x0000ff00
# define kMaskAscii1 0x00ff0000
# define kMaskAscii2 0x000000ff
# define period '.'
pascal Boolean
SkelCmdPeriod (EventRecord *evt)
{
short keyCode;
long virtualKey;
long keyCId;
long keyInfo;
# if skelUnivHeaders >= 2 && skelUnivHeadersMinor > 0
unsigned long state;
# else
long state;
# endif
long lowChar, highChar;
Handle hKCHR;
if (evt->what == keyDown || evt->what == autoKey)
{
if (evt->modifiers & cmdKey) /* cmd key is down */
{
/* find out ASCII equivalent for key */
virtualKey = (evt->message & kMaskVirtualKey) >> 8;
/* "and" out command key, "or" in the virtual key */
keyCode = (evt->modifiers & kMaskModifiers) | virtualKey;
#if skelUnivHeaders
keyCId = GetScript (GetScriptManagerVariable (smKeyScript), smScriptKeys);
#else
/* can't use new name for this one in non-universal headers */
keyCId = GetScript (GetEnvirons (smKeyScript), smScriptKeys);
#endif
hKCHR = GetResource ('KCHR', keyCId);
if (hKCHR != (Handle) nil)
{
state = 0;
/*
* Don't bother locking because KeyTrans doesn't move memory.
* If you get a prototype error on the next line, it's probably
* because skelUnivHeadersMinor wasn't computed properly in
* TransSkel.h and thus the type for state wasn't determined
* correctly.
*/
keyInfo = KeyTranslate (*hKCHR, keyCode, &state);
ReleaseResource (hKCHR);
}
else
keyInfo = evt->message;
lowChar = keyInfo & kMaskAscii2;
highChar = (keyInfo & kMaskAscii1) >> 16;
if (lowChar == period || highChar == period)
return (true);
}
}
return (false);
}